/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.appleframework.vfs;

import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.Channel;
import java.util.List;

/**
 *
 * @author zhujg
 */
public abstract class VirtualFile {

  public abstract String getName();
  public abstract boolean isDirectory();
  public abstract String relativePath();
  public abstract List<VirtualFile> list();
  public abstract boolean exists();
  public abstract InputStream inputstream();
  public abstract OutputStream outputstream();
  public abstract VirtualFile child(String name);
  public abstract Long lastModified();
  public abstract long length();
  public abstract Channel channel();

  public static VirtualFile open(String file){
    return open(new File(file));
  }

  public static VirtualFile open(File file){
    if(file.isDirectory()){
      return new FileSystem(file);
    }
    return null;
  }

  public String contentToString(){
    return "";
  }

  @Override
  public String toString(){
    return getName();
  }
}
